package Iterator;

/**
 * @Grup:Iterator
 * @Auther:cola
 * @Data:2021/3/29-2021-03-23:19
 * @version:1.0
 * 容器接口具体实现类
 */
public class ConcreteAggregate implements MyList{
   private Object[] elements;
   private int size;
   private int index;

    public ConcreteAggregate() {
        elements=new Object[100];
    }

    @Override
    public void add(Object e) {
        elements[index++]=e;
        size++;
    }

    @Override
    public Object get(int index) {
        return elements[index];
    }

    @Override
    public Iterators iterator() {
        return new ConcreteIterator(this);
    }

    @Override
    public int getSize() {
        return size;
    }
}
